<?php
namespace froyo\cherry\Base;

use froyo\cherry\Exception\HttpException;

abstract class BaseLogger extends BaseObject{
	const LEVEL_ERROR = 'error';
	const LEVEL_INFO = 'info';
	const LEVEL_DEBUG = 'debug';
	public $level = 'info';
	public $stands = [];


	abstract function writelog($type,$msg);

	public function info($msg){
		return $this->log(self::LEVEL_INFO,$msg);
	}

	public function error($msg){
		return $this->log(self::LEVEL_ERROR,$msg);
	}

	public function debug($msg){
		return $this->log(self::LEVEL_DEBUG,$msg);
	}



	public function log($level,$msg)
	{
		$num = $this->getLevelNum($level);
		if($num<=$this->getLevelNum($this->level))
		{
			return $this->writelog($level,$msg);
		}
	}
	public function getLevelNum($level){
		$levelnum = 0;
		switch ($level) {
			case 'debug':$levelnum =10;break;
			case 'error':$levelnum =5;break;
			case 'info':$levelnum =7;break;
				# code...
				break;
			
			default:
				$levelnum = 6;break;
		}
		return $levelnum;
	}
}